package com.kly.test.function.home

import android.os.Build
import android.view.ViewGroup
import androidx.annotation.RequiresApi
import androidx.recyclerview.widget.RecyclerView
import com.kly.test.base.adpater.BasePagedAdapter
import com.kly.test.function.home.viewmodel.ItemType
import com.kly.test.model.HomeListDataBean

class HomeDataListAdapter : BasePagedAdapter() {
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
        return when (viewType) {
            ItemType.HomeListData -> HomeDataListViewHolder(parent, callback)
            else -> super.onCreateViewHolder(parent, viewType)
        }
    }

    @RequiresApi(Build.VERSION_CODES.S)
    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
        val item = getItem(position)
        when (holder) {
            is HomeDataListViewHolder -> item?.data<HomeListDataBean>()
                ?.let { holder.bind(it, position) }
        }
    }
}